package encrypt

import (
	"crypto/hmac"
	"crypto/sha256"
)

// Base64Sha256Encode 字串sha256后再base64编码
func Base64Sha256Encode(key, src []byte) string {
	if len(src) == 0 {
		return ""
	}
	// Create a new HMAC by defining the hash type and the key (as byte array)
	h := hmac.New(sha256.New, key)
	h.Write(src)
	sum := h.Sum(nil)
	return base64Std.EncodeToString(sum)
}
